import React, {useContext} from 'react';
import {View, Text} from 'react-native';
import {Button} from '@rneui/base';
import {useMount} from 'ahooks';
import GlobalContext from '@/GlobalContext';

import {createDrawerNavigator} from '@react-navigation/drawer';
const DrawerStack = createDrawerNavigator();

import style from './style.less';
import {Drawer} from 'react-native-drawer-layout';

const A = ({navigation}) => {
  const [open, setOpen] = React.useState(true);

  return (
    <>
      <Drawer
        open={open}
        onOpen={() => setOpen(true)}
        onClose={() => setOpen(false)}
        renderDrawerContent={() => {
          return <Text>Drawer content</Text>;
        }}
        drawerType="back"
        hideStatusBarOnOpen={true}
      >
      <Button
        onPress={() => setOpen(prevOpen => !prevOpen)}
        title={`${open ? 'Close' : 'Open'} drawer`}
      />
      </Drawer>
    </>
  );
  
};
const B = () => {
  return (
    <View style={style.box}>
      <Text>BBB</Text>
      <Button
        title="打开B页面"
        containerStyle={{marginTop: 10}}
        onPress={() => {
          console.log(navigation);
          navigation.navigate('B');
        }}
      />
    </View>
  );
};
const C = () => {
  return <Text>C</Text>;
};
export default ({navigation}) => {
  return (
    <DrawerStack.Navigator>
      <DrawerStack.Screen
        name="A"
        component={A}
        options={{headerShown: false}}
      />
      <DrawerStack.Screen name="B" component={B} />
      <DrawerStack.Screen name="C" component={C} />
    </DrawerStack.Navigator>
  );
};
// export default ({navigation}) => {
//   return (
//     <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
//       <Text>OK V2.1.6</Text>
//     </View>
//   );
// };
